home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / psion / font.fmt < prev    next >
Text File  |  1995-03-31  |  4KB  |  85 lines

  1. PSIONICS FILE - FONT.FMT
  2. ========================
  3. Format of Font files
  4. Last modified 1994-09-13
  5. ========================
  6.  
  7. A font file holds a font for loading with the GLOADFONT keyword. There are two
  8. kinds of font files, standard and fast. The formats are related; the notation
  9. "A // B" means A for normal fonts, and B for fast fonts.
  10.  
  11. The font file consists of a header, a width table, and a bitmap, with no
  12. intervening space. The header is 62 bytes, and has the format:
  13.   Offset  0 (byte): 'F' (70)
  14.   Offset  1 (byte): 'O' (79) // 'N' (78)
  15.   Offset  2 (byte): 'N' (78) // '1' (49)
  16.   Offset  3 (byte): 227      // 197
  17.   Offset  4 (byte):  48      //  16
  18.   Offset  5 (byte):  48      //  16
  19.   Offset  6 (word): checksum (see below)
  20.   Offset  8 (word): size from offset 10 to end of bitmap data
  21.   Offset 10 (word): lowest character code
  22.   Offset 12 (word): highest character code
  23.   Offset 14 (word): height of font
  24.   Offset 16 (word): descent of font
  25.   Offset 18 (word): ascent of font
  26.   Offset 20 (word): width of numeric characters
  27.   Offset 22 (word): widest character in font
  28.   Offset 24 (word): flag bits:
  29.     Bit 0: the font uses ASCII for codes  32 to 126
  30.     Bit 1: the font uses Code Page 850 for codes 128 to 255
  31.     Bit 2: bold font
  32.     Bit 3: italic font
  33.     Bit 4: serifed font
  34.     Bit 5: monospaced font
  35.   Offset 26 to  41: font name (padded with spaces)
  36.   Offset 42 (word): [appears to be size of the width table in bytes]
  37.   Offset 44 (word): [unknown: 0, 0, 0, 0]
  38.   Offset 46 (word): [unknown: 0, 0, 0, 0]
  39.   Offset 48 (word): [unknown: -9, -7, 72, 46]
  40.   Offset 50 (word): [appears to be height of font again: 8, 8, 6, 9]
  41.   Offset 52 (word): [appears to be width of bitmap in bytes: 256, 256, 10, 6]
  42.   Offset 54 (word): [unknown: 0, 0, 0, 0]
  43.   Offset 56 (word): [appears to be 8 * height of font: 64, 64, 48, 72]
  44.   Offset 58 (word): [unknown: 2, 2, 2, 2]
  45.   Offset 60 (word): [unknown: 0, 0, 0, 0]
  46.  
  47. The meanings of the fields from offset 42 onwards are not known. @The numbers
  48. shown are their values in the system normal font, the system bold font, the
  49. system digit font, and the Spreadsheet small font (the first two are fast
  50. fonts and the latter two normal fonts).@
  51.  
  52. The checksum is the X^16+X^12+X^5+1 polynomial, applied to the width table and
  53. the bitmap. See the system call GenCrc.
  54.  
  55. The header is followed, at offset 62, by the width table. For normal fonts,
  56. the header contains one word for each character in the font, plus an extra
  57. word. Thus if the font contains characters 48 to 52, there will be 6 words in
  58. the table. The first word in the table corresponds to the lowest character
  59. code, up to the last word but one, which corresponds to the highest character
  60. code. For each entry except the last, if the character exists in the font,
  61. then the corresponding word is twice the horizontal position of the start of
  62. the character in the bitmap. If the character does not exist, then the word
  63. is the same as the following word, but with the bottom bit set. The final entry
  64. in the table is twice the width of the bitmap. Thus the bottom bit indicates
  65. whether the character exists or not, and for any character which exists, its
  66. width is given by subtracting the entry from the following entry and dividing
  67. by two (this applies equally to the last character, which is why the extra
  68. entry is there).
  69.  
  70. For fast fonts, the width table is 256 bytes, from offsets 62 to 317 inclusive.
  71. Each byte holds the width (from 0 to 8) of the corresponding character.
  72.  
  73. The bitmap immediately follows the width table (thus for normal fonts it starts
  74. at offset (66 + (max_code - min_code) * 2), while for fast fonts it starts at
  75. offset 318). Its size is calculated from the size field in the header, and will
  76. always be a multiple of the height. The data for each row is kept together,
  77. with the rows in order from top to bottom. For each row, the data represents
  78. blocks of 8 pixels per byte; the bytes are in left to right order, and the
  79. least significant bit in the byte represents the leftmost pixel of the block.
  80. For normal fonts, each character occupies a number of columns, with all the
  81. characters that exist in the font being placed side by side in code order.
  82. For a fast font, the character occupies the left side of a block of 8 columns,
  83. again in code order (i.e. character code C occupies byte C of each row, so
  84. its top row is at offset 318+C, its second row at offset 574+C, and so on).
  85.